import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const types = {
  SET_TOKEN: 'SET_TOKEN',
  REMOVE_TOKEN: 'REMOVE_TOKEN',
  SET_USERINFO: 'SET_USERINFO',
}

const store = new Vuex.Store({
  state: {
    isAuth: false, // 是否登陆且通过认证
    token: null,
    userInfo: null
  },
  mutations: {
    [types.SET_TOKEN]: (state, data) => {
      state.token = data;
    },
    [types.REMOVE_TOKEN]: (state) => {
      state.token = null;
    },
    [types.SET_USERINFO]: (state, data) => {
      state.userInfo = data;
    },
  },
  actions:{

  }
})

export default store